Avorion Script API Documentation

Faction [Server]

This object is only available on the server.

function Faction(var index)

Returns

A new instance of Faction

property bool alwaysAtWar
property string baseName
property string fullLogId[read-only]
property bool homeSectorUnknown
property int index[read-only]
property bool infiniteResources
property int initialRelations
Note: AIFactions only
property int initialRelationsToPlayer
Note: AIFactions only
property bool isAIFaction[read-only]
property bool isAlliance[read-only]
property bool isPlayer[read-only]
property int money
property string name[read-only]
property string stateForm
property bool staticRelationsToAI
property bool staticRelationsToAll
property bool staticRelationsToPlayers
property Format unformattedName[read-only]

function var addPlanStyle(string name, PlanStyle style)

Returns

nothing

function bool, string, table<int, string> canPay()

function bool, string, table<int, string> canPayMoney(int money)

function bool, string, table<int, string> canPayResource(Material material, int amount)

function var clearValues()

Removes all custom values of the object

Returns

nothing

function Relation... getAllRelations()

function int, int getHomeSectorCoordinates()

function Inventory getInventory()

function Language getLanguage()

function PlanStyle getPlanStyle(string name)

function string... getPlanStyleNames()

function Relation getRelation(int otherFactionIndex)

function int getRelations(int factionIndex)

function int getRelationStatus(int factionIndex)

function int... getResources()

function float getTrait(string trait)

Retrieves a trait value associated with a key

Parameters

trait The name of the trait

Returns

The trait value associated with the key

function table<string, float> getTraits()

Retrieves all key-value trait pairs of the faction

Returns

A table containing all custom key-value pairs

function var getValue(string key)

Retrieves a custom value saved in the entity with the given key

Parameters

key A string that serves as the name of the value

Returns

The value if the key exists, otherwise nil

function table<string, var> getValues()

Retrieves all key-value pairs of custom values

Returns

A table containing all custom key-value pairs

function bool hasStaticRelationsToFaction(int factionIndex)

function bool knowsFaction(int factionIndex)

function var pay(string or Format [optional] description, int money, int... resources)

Makes the faction pay a certain amount of money and resources. If the faction can't pay, the respective money and resources will be set to 0. This function accepts an optional string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.
To ease handling of transaction descriptions, the format description (if set) will receive all the remaining arguments given to the pay() function as format arguments, in the same order as they are given to the function. Dots for easier reading will be inserted as well. Examples:

faction:pay("Paid %1% Credits and %2% iron.", 50000, 250)
-> "Paid 50.000 Credits and 250 iron."

faction:pay(Format("%1% paid %2% Credits and %3% iron.", "Excelsior"), 50, 25000)
-> "Excelsior paid 50 Credits and 25.000 iron."

Parameters

description [optional] A description for the transaction. Can either be a string or a Format. If this variable is set, money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be removed from the faction
resources A list of resources, starting with iron, that will be removed from the faction

Returns

nothing

function var payResource(string or Format description, Material material, int amount)

Makes the faction pay a certain amount of resources. If the faction can't pay, the respective resource will be set to 0. This function accepts a string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.

Parameters

description A description for the transaction. Can either be a string or a Format.
material The kind of material that will be removed from the faction
amount Amount that will be removed from the faction

Returns

nothing

function var payWithoutNotify(string or Format description, int money, int... args)

Similar behavior to pay(), except there will not be a notification popping up in case the faction is a player, and the description for the transaction in this function isn't optional.

Parameters

description A description for the transaction. Can either be a string or a Format. Money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be removed from the faction
args A list of resources, starting with iron, that will be removed from the faction

Returns

nothing

function var receive(string or Format [optional] description, int money, int... resources)

Makes the faction receive a certain amount of money and resources. This function accepts an optional string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.
To ease handling of transaction descriptions, the format description (if set) will receive all the remaining arguments given to the receive() function as format arguments, in the same order as they are given to the function. Dots for easier reading will be inserted as well. Examples:

faction:receive("Got %1% Credits and %2% iron.", 50000, 250)
-> "Got 50.000 Credits and 250 iron."

faction:receive(Format("%1% received %2% Credits and %3% iron.", "Excelsior"), 50, 25000)
-> "Excelsior received 50 Credits and 25.000 iron."

Parameters

description [optional] A description for the transaction. Can either be a string or a Format. If this variable is set, money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be given to the faction
resources A list of resources, starting with iron, that will be given to the faction

Returns

nothing

function var receiveResource(string or Format description, Material material, int amount)

Makes the faction receive a certain amount of resources. This function accepts a string for Format as first argument, as an economy notification describing the transaction that will be sent to the player, in case the faction is a player.

Parameters

description A description for the transaction. Can either be a string or a Format.
material The kind of material that will be given to the faction
amount Amount that will be given to the faction

Returns

nothing

function var receiveWithoutNotify(string or Format description, int money, int... args)

Similar behavior to receive(), except there will not be a notification popping up in case the faction is a player, and the description for the transaction in this function isn't optional.

Parameters

description A description for the transaction. Can either be a string or a Format. Money and resources will be appended to the end of the list of arguments passed to the description format string.
money Money that will be given to the faction
args A list of resources, starting with iron, that will be given to the faction

Returns

nothing

function var sendCallback()

Returns

nothing

function var sendChatMessage()

Returns

nothing

function var setHomeSectorCoordinates(int x, int y)

Returns

nothing

function var setLanguage(Language language)

Returns

nothing

function var setResources()

Returns

nothing

function var setStaticRelationsToFaction(int factionIndex, bool in)

Returns

nothing

function var setTrait(string trait, float value)

Sets a trait value associated with a key

Parameters

trait The name of the trait
value The value of the trait, should be between -1 and 1

Returns

nothing

function var setValue(string key, var value)

Sets a custom value

Parameters

key A string that serves as the name of the value
value The value to save. Must be bool, number, string or nil. If nil is given, the value will be deleted.

Overview
Home Functions Search
Search:

This is the official documentation for the scripting API of Avorion. This documentation is automatically generated and not necessarily complete. Depending on the context in which functions exist, some documentation such as descriptions, return values or variable names or types may be missing.

Work in Progress. Documentation of Avorion Version: 2.5.7 c8e4beec84f7